<?  
	$title="Photo Gallery"; 
	$pageid="3";
	$accessid="a00";
	require("required/dbconnect.php");
	require("required/function.php");
	require("required/header.php");
	
	

	$action=$_GET['action'];
	
	
	if($action=="new")  
	{
		$product_id=$_GET['aid'];
		$errormsg="";
	
	
	
		
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
<script type="text/javascript" src="uploadify/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="uploadify/jquery.uploadify.js"></script>

<script type="text/javascript">

$(document).ready(function() {
	$("#fileUploadstyle").fileUpload({
		'uploader'		 : 'uploadify/uploader.swf',
		'cancelImg'		 : 'images/icons/cancel.png',
		'script'         : 'productpic_upload2.php?ajaxupload=1&id=<?= $product_id ?>',
		'scriptData'	 : {'ajaxId': '<?= $product_id ?>'},
		'folder'		 : 'files',
		'multi'			 : true,
		'displayData'	 : 'speed',
		'buttonImg'		 : 'images/browseBtn.png',
		'width'			 : 80,
		'height'		 : 24,
		 'rollover'		 : true,
                'onAllComplete'	 : function(event, queueID, fileObj, response, data)
                                   { 
                                        alert("Uploaded Successfully!");  
                                   } 
		
	});

	
});

</script>

<?
/*
<script type="text/javascript">
$(document).ready(function() {
	$("#fileUploadstyle").fileUpload({
		'uploader'		 : 'uploadify/uploader.swf',
		'script'         : 'productpic_upload2.php?ajaxupload=1&id=<?= $product_id ?>',
		//'script'         : 'scripts/uploadify.php?ajaxupload=1&id=<?= $product_id ?>',
		'scriptData'	 : {'id': '<?= $product_id ?>'},
		'cancelImg'      : 'images/icons/cancel.png',
		'folder'         : 'uploads',
		'queueID'        : 'fileQueue',
		'buttonText'	 : 'Browse Files',
		'displayData'	 : 'speed',
		'buttonImg'	 	 : 'images/browseBtn.png',
		'width'			 : 80,
		'height'		 : 24,
		'rollover': true
		'fileExt'        : '*.jpg;*.gif;*.jpeg;*.JPEG;*.JPG;*.GIF;*.png;*.PNG',
		'multi'          : true,
		onError		 	 : function(e, q, f, o) {
		 		if(o.info==405)
				{
					alert("Invalid file format!");
				}else{
					alert("Error :"+o.info);
				}
				//document.getElementById(divName).innerHTML="ERROR: " + o.info;
		  }


	});
	
	
});
</script>

*/ ?>
	
	<td  width="84%" align="left" valign="top">
		<table width="95%"  cellpadding="2" cellspacing="1">
			<td width="100%" valign="top">
				<table class="solidborder" width="100%">
				<tr style="background-image: url(images/tbl_th.png);color:#FFFFFF" align="center" height="18">
					<td>Upload Photo</td>
				</tr>
				  
				<tr>
					<td>
               <div id="fileUploadstyle">You have a problem with your javascript</div>
		<a href="javascript:$('#fileUploadstyle').fileUploadStart()">Start Upload</a> |  
        <a href="javascript:$('#fileUploadstyle').fileUploadClearQueue()">Clear Queue</a> |
        <a href="product_viewfull.php?id=<?= $product_id ?>">Back</a>
               
                <p>
                	
                	
                </p>
					  </td>
				</tr>
				<tr> 
					<td valign=top align="left"> 
					<ul>
					<li>The file must be in jpg,gif or png format.</li>
					<li>Do not upload photos containing nudity or copyrighted images.</li>
					</ul>
					</td>
				</tr>
				
				
			  </table><br>
		</td>
		</table>
		</td>
</table>

<? 
}
elseif($action=="edit")  
{
	$photo_id=$_GET['pid'];
	$id=$_GET['aid'];
	$errormsg="";
	
	
	
	$get_photo=mysql_fetch_array(mysql_query("select * from os_productpic where id=$photo_id"),MYSQL_ASSOC);
		
	if(mysql_num_rows(mysql_query("select * from os_productpic where id=$photo_id"))==0)
	{
		die("Illegal operation!");
	}	
	
	if($get_photo["width"]>300 or $get_photo["height"]>250)
	{
		if($get_photo["width"]-$get_photo["height"]>0)
		{
			$pfix="width=300";
			
		}
		else
		{
			$pfix="height=250";
			
		}						
	}
	else
	{
		$pfix="";
		
	}
	
	
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
				<script language="JavaScript" type="text/javascript" src="wysiwyg.js">
				</script>
					<td width="16%" valign="top">
						<? require("required/menu.php") ?>
					</td>
					<td width="84%" align="left" valign="top">
	<table width="95%" class="contentfont"  cellpadding="0" cellspacing="0">
	
	<td width="100%" valign="top">
		<table class="solidborder" width="100%">
  	 	<tr style="background-image: url(images/tbl_th.png);color:#FFFFFF" align="center" height="18">
			<td>Update photo</td>
		</tr>
		<tr>
			<td align="center">
				
				<img src="../productpic/<?= $get_photo['name'] ?>" <?= $pfix ?> alt="<?= $get_photo['caption'] ?>">
			</td>
		</tr>
    <form method="post" enctype="multipart/form-data" action="productpic_upload2.php">
  	<tr>
		<td>
		<font color=red><?= $errormsg ?></font>
		<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
		  Change photo:<br> 
          <input type="file" name="file" class=button size="40"><br>
		  Caption:<br>
		  <input type="text" name="caption" class="text" size="40" value="<?= $get_photo['caption'] ?>"><br>
		  Order ID:<br>
		  <input type="text" name="order_id" class="text" size="5" maxlength="2" value="<?= $get_photo['order_id'] ?>"><br><br>
		  <input type="hidden" name="action" value="edit">
		  <input type="hidden" name="photo_id" value="<?= $photo_id ?>">
		  <input type="hidden" name="aid" value="<?= $id ?>">
		  <input type="hidden" name="name" value="<?= $get_photo['name'] ?>">
		  <input type="submit" value="upload" name=submit class=button> <input type="button" value="back" onclick="window.open('product_viewfull.php?id=<?= $_GET['aid'] ?>','_self')" class=button>
          </td>
    </tr>
	<tr> 
		<td valign=top align="left"> 
		<ul>
		<li>Max Width: 2000px Max Height:1000px</li>
		<li>The file size must be less than 2MB</li>
		<li>The file must be in jpg or gif format.</li>
		<li>Do not upload photos containing nudity or copyrighted images.</li>
		</ul>
		</td>
	</tr>
	</form>
  </table><br>
</td>
</table>
</td>
	
</table>

<? }else{ 

?>
<td colspan="3" width="<?= $contentwidth ?>" height="100"  bgcolor="#FFFFFF" valign="top" align="center">
	
  Invalid!!
</td>
<?
}
require("required/footer.php") ?>
	

